package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ConstructorDemo02 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Class<Rectangle> rectangleClass = Rectangle.class;
        Constructor<Rectangle> constructor = rectangleClass.getDeclaredConstructor(int.class, int.class);
        constructor.setAccessible(true);
        Rectangle rectangle = constructor.newInstance(10, 20);
        int tPerimeter = rectangle.getPerimeter();
        System.out.println("矩形周长："+tPerimeter);
    }
}
